<%= render 'node_selector', node: @topic.node %>
<%= render 'team_selector', node: @topic.team %>

<%= form_for @topic, remote: true, html: { class: "form", tb: 'edit-topic' } do |f| %>

  <%= render "shared/error_messages", target: @topic %>
  <%= f.hidden_field :node_id %>

  <div class="form-group">
    <div class="input-group">
      <div class="input-group-prepend">
        <button type="button" class="btn btn-default" id="node-selector-button"
          data-toggle="modal" data-target="#node-selector">
          <%= @topic.node&.name || '选择节点...' %>
        </button>
      </div>
      <%= f.text_field :title, class: "form-control", placeholder: "在这里填写标题" %>
    </div>
  </div>

  <%= render "/shared/editor_toolbar" %>

  <div class="form-group">
    <%= f.text_area :body, class: "topic-editor form-control closewarning", rows: 20 %>
  </div>

  <span class="help-inline">
    <label>
      <%= f.check_box :cannot_be_shared %>  <%= t("topics.cannot_be_shared")%>
    </label>
  </span>

  <% if Setting.has_module?(:team) %>
    <% if current_user.team_options.any? %>
      <%= f.hidden_field :team_id %>
      <div class="form-group" id="team_selector_wrapper">
        <input id="team-selector-button" data-toggle="modal" data-target="#team-selector" type="button" class="form-control" value="<%= @topic.team&.name || '选择我的社团...' %>">
        <span class="team-clear" aria-hidden="true"><i class="fas fa-times"></i></span>
      </div>
    <% end %>
  <% end %>

  <div class="form-actions hide-ios">
    <%= f.submit t("common.save"), class: "btn btn-primary", style: "min-width: 200px", 'data-disable-with' => t("common.saving"), 'data-tb' => "save-topic" %>

    <% if @topic.draft or @topic.new_record? %>
    <span>or</span>
    <%=	 button_tag  t("common.save_as_draft"), name: 'commit',id: 'save_as_draft', value: 'draft', type: 'submit', class: "btn btn-info", 'data-disable-with' => t("common.saving_as_draft"), 'data-tb' => "save-topic-draft"  %>
    <%	end %>

    <div class="pull-right hide-ios"><a href="/markdown" target="_blank"><i class="fa fa-life-ring"></i> 排版说明</a></div>
  </div>
<% end %>
